<?php
class Getvq_con extends Lxbase{
	public $vqdb;
	public function index(){
		$key=$_GET["key"];
		$t=$_GET["t"];
		if(empty($t)){
			$u=intval($_GET["u"]);
			$t = $this->oncedata("token","users","where id={$u}");
		}
		$urlhost = empty($_SERVER["SERVER_NAME"])?$_SERVER["HTTP_HOST"]:$_SERVER["SERVER_NAME"];
		if($urlhost == 'kaifa.zq.zhongsou.com' || $urlhost=='zq.zhongsou.com'){
			$dbconn = array( "host"=>'103.7.222.62', "user"=>'root', "pass"=>'zhs20151117', "name"=>'qiyuedb_new');
			$vqurl='http://kaifa.vq.zhongsou.com';
		}else{
			$dbconn = array( "host"=>'103.7.222.41', "user"=>'b2ctest', "pass"=>'B2@c@2tE8T', "name"=>'qiyuedb');
			$vqurl='http://vq.zhongsou.com';
		}
		$vqdb = new Lxbase($dbconn);
		$list = $vqdb->arrdata("id,text,pic,url,title","tp_img","where token='{$t}' and keyword regexp replace('{$key}',' ','|')","usort desc","limit 6");
		foreach($list as $k=>$v){
			if(empty($list[$k]["url"])){
				$list[$k]["url"]=$vqurl."/?g=Wap&a=content&token={$t}&id={$list[$k]['id']}";
			}else{
				$list[$k]["url"] = str_replace('{siteUrl}',$vqurl,$list[$k]["url"]);
			}
		}
		echo json_encode($list);
		exit;
	}

}